package com.ds.infra.rpc.autoconfigure.condition;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * 作用：RPC服务提供者条件判断实现
 *
 * @author WeiShaoying
 */
public class OnRpcProviderCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        String role = context.getEnvironment().getProperty("rpc.role");
        return "provider".equalsIgnoreCase(role) ||
                context.getEnvironment().containsProperty("rpc.provider.enabled");
    }
}
